package lab02.test24;

public class GetDays {

    public int getDays(int month,int year){//传入月份和年份
        int sumDays = 0;

        switch (month) {
            case 12: {
                sumDays += 31;
                break;
            }
            case 11: {
                sumDays += 30;
                break;
            }
            case 10: {
                sumDays += 31;
                break;
            }
            case 9: {
                sumDays += 30;
                break;
            }
            case 8: {
                sumDays += 31;
                break;
            }
            case 7: {
                sumDays += 31;
                break;
            }
            case 6: {
                sumDays += 30;
                break;
            }
            case 5: {
                sumDays += 31;
                break;
            }
            case 4: {
                sumDays += 30;
                break;
            }
            case 3: {
                sumDays += 31;
                break;
            }
            case 2: {
                    /*判断当前年份是否为闰年*/
                if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
                    sumDays += 29;
                    break;
                } else {
                    sumDays += 28;
                    break;
                }

            }
            case 1: {
                sumDays += 31;
                break;
            }

            default: {
                System.out.println("月份错误！！");
            }

        }
        return sumDays;
    }
}
